#ifndef __CAN_MOTOR_DRV_H__
#define __CAN_MOTOR_DRV_H__
#include "main.h"
#include "can.h"
#include "bsp_can.h"

/**
 * @brief 	电机参数结构体
 */
typedef enum
{
	RUN = 0,
	STOP = 1,
	ANGLE_YES = 3,
	ANGLE_NO = 4,
}MOTOR_MEASURE_STATE;
typedef struct{
	uint32_t stdID;					//电机的标准canID
	
	float target_speed;				//电机目标转速
	float target_angle;			//电机目标转过的角度值(用于角度环pid)
	
	float speed_rpm_now;			//电机当前转速,单位:rpm
	float speed_rpm_last;			//电机上次转速
	
	float angle_now;				//电机转子当前角度	角度制	[0,360)
	float angle_last;				//电机转子上次角度
	
	float angle_total;				//电机转过总角度(用于角度环pid,正负代表不同方向)
	
	MOTOR_MEASURE_STATE state;					//电机运行状态	 RUN 或者 STOP
	MOTOR_MEASURE_STATE angle_mode;				//角度环pid模式	ANGLE_YES（进行角度环） 
													//或者 ANGLE_NO（不进行角度环pid）
}Motor_measure_t;


void Can_Motor_cmd(CAN_HandleTypeDef* hcan,uint16_t ID,int16_t c1,int16_t c2,int16_t c3,int16_t c4);
void Can_Motor_filter_config(void);
void Can_Motor_measure_t_config(
	Motor_measure_t* pmmt,
	MOTOR_MEASURE_STATE state,
	MOTOR_MEASURE_STATE	angle_mode,
	uint32_t stdID
);
#endif 
